<html>
<head>
	<title>Excersise 5</title>
	<link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>


		var arr = [11,4,31,2,31,62,3,24,2,5,12,31];

		jsConsole.writeLine('The searched number occurres ' + numberInAnArray(arr, 31) + ' times in the array.'); //Invoking function
		
		function numberInAnArray(array, number){
			jsConsole.writeLine('The given array is: '+arr);
			jsConsole.writeLine('The searched number is: '+number)
			var counter = 0;
			for (var i = 0; i < arr.length; i++) {
				if(arr[i] == number)
				{
					counter++;
				}
			};
			return counter;
		}
	</script>
</body>
</html>
